<template>
    <view class="balance-page">
        <view class="tab-container">
            <view class="tab-section" :class="{ active: currentTab === 0 }" @click="switchTab(0)">
                <text>余额明细</text>
                <view class="tab-underline" v-if="currentTab === 0"></view>
            </view>
            <view class="tab-section" :class="{ active: currentTab === 1 }" @click="switchTab(1)">
                <text>充值记录</text>
                <view class="tab-underline" v-if="currentTab === 1"></view>
            </view>
        </view>

        <view class="content-container">
            <view class="empty-state" v-if="isEmpty">
                <image class="empty-icon" src="/static/images/empty-doc.png" mode="aspectFit"></image>
                <text class="empty-text">没有相关信息</text>
            </view>

            <!-- 余额明细内容 -->
            <view class="record-list" v-if="currentTab === 0 && !isEmpty">
                <!-- 余额明细记录 -->
            </view>

            <!-- 充值记录内容 -->
            <view class="record-list" v-if="currentTab === 1 && !isEmpty">
                <!-- 充值记录 -->
            </view>
        </view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            currentTab: 0,
            records: {
                balance: [],
                recharge: []
            }
        }
    },
    computed: {
        isEmpty() {
            if (this.currentTab === 0) {
                return this.records.balance.length === 0;
            } else {
                return this.records.recharge.length === 0;
            }
        }
    },
    onLoad() {
        // 加载余额明细数据
        this.loadData();
    },
    methods: {
        switchTab(index) {
            if (this.currentTab !== index) {
                this.currentTab = index;
                this.loadData();
            }
        },
        loadData() {
            // 根据当前标签加载对应数据
            if (this.currentTab === 0) {
                // 加载余额明细
                // this.records.balance = ...
            } else {
                // 加载充值记录
                // this.records.recharge = ...
            }
        }
    }
}
</script>

<style lang="scss" scoped>
.balance-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: #f5f5f5;
}

.tab-container {
    display: flex;
    background-color: #fff;
    border-bottom: 1px solid #eee;
}

.tab-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 0;
    position: relative;

    text {
        font-size: 16px;
        color: #999;
    }

    &.active {
        text {
            color: #333;
            font-weight: bold;
        }

        .tab-underline {
            width: 40px;
            height: 3px;
            background-color: #7FB992;
            position: absolute;
            bottom: 0;
            border-radius: 2px;
        }
    }
}

.content-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 100px 0;
}

.empty-icon {
    width: 100px;
    height: 100px;
    margin-bottom: 20px;
    opacity: 0.6;
}

.empty-text {
    color: #999;
    font-size: 14px;
}
</style>
